//
//  ViewController.m
//  movement
//
//  Created by iD Student on 7/30/13.
//  Copyright (c) 2013 idstudent. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    gameTimer = [NSTimer scheduledTimerWithTimeInterval:.1 target:self selector:@selector(gameUpdate) userInfo:nil repeats:YES];
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    
    // Dispose of any resources that can be recreated.
}

- (IBAction)leftpressed:(id)sender
{
 goingLeft = YES;
 goingRight = NO;
}

- (IBAction)downpressed:(id)sender
{
    goingDown = YES;
    goingUp = NO;
}

- (IBAction)rightpressed:(id)sender
{
   goingRight = YES;
    goingLeft = NO;
}

- (IBAction)uppressed:(id)sender
{
   goingUp = YES;
    goingDown = NO;
}
- (void) gameUpdate
{
    if(goingUp == YES)
    {
        CGPoint oldCenter = movingImage.center;
        movingImage.center = CGPointMake(oldCenter.x, oldCenter.y - 3);
    }
     if(goingDown == YES)
    {
        CGPoint oldCenter = movingImage.center;
        movingImage.center = CGPointMake(oldCenter.x, oldCenter.y + 3);
    }
    
    if(goingRight == YES)
    {
        
        CGPoint oldCenter = movingImage.center;
        movingImage.center = CGPointMake(oldCenter.x + 3, oldCenter.y);
    }
    if(goingLeft == YES)
    {
       CGPoint oldCenter = movingImage.center;
        movingImage.center = CGPointMake(oldCenter.x -3 , oldCenter.y);
    }
}
@end
